package com.uniview.config;

import com.uniview.annotation.RequestMappingScan;
import com.uniview.locator.ResourceLocator;
import com.uniview.properties.OpenScanProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author lux
 * @date: 2019/12/26
 * @desc:
 */
@Slf4j
@Configuration
public class AutoConfiguration {
    @Bean
    @ConditionalOnMissingBean(RequestMappingScan.class)
    public RequestMappingScan resourceAnnotationScan(AmqpTemplate amqpTemplate, OpenScanProperties scanProperties) {
        RequestMappingScan scan = new RequestMappingScan(amqpTemplate,scanProperties);
        log.info("RequestMappingScan [{}]", scan);
        return scan;
    }

    @Bean
    @ConditionalOnMissingBean(ResourceLocator.class)
    public ResourceLocator resourceLocator(){
        ResourceLocator resourceLocator = new ResourceLocator();
        return resourceLocator;
    }

}
